Page({
  data: {
    total_money: '', //总收益
    today_money: '', //今日收益
    yesterday_money: '', //昨日收益
    rewardList: [],
    /**【1-进行审核中(隐藏)2-已上线(不隐藏)】 */
    isShow: 2,
  },

  onLoad(options) {
    this.request({
      url: 'user/isShow',
    }).then(res => {
      console.log("isshow", res);
      this.setData({
        isShow: res.data
      })
    });
  },
  onShow() {
    const authorization = wx.getStorageSync('Authorization');
    if (!authorization) {
      wx.showModal({
        title: '检测到您还未登录',
        content: '是否登录小程序',
        confirmColor: '#F11224',
        complete: res => {
          if (res.confirm) {
            this.getStatistics();
            wx.switchTab({
              url: '/pages/user/user',
            });
          } else {
            wx.switchTab({
              url: '/pages/index/index',
            })
          }
        },
      });
    } else {
      this.getStatistics();
    }
  },
  getStatistics() {
    this.request({
      url: 'user/money/statistics',
    }).then(res => {
      console.log(res.data.money_type);
      this.setData({
        total_money: res.data.total_money,
        today_money: res.data.today_money,
        yesterday_money: res.data.yesterday_money,
        rewardList: res.data.money_type,
      });
    });
  },
});